{% extends "base.html" %}

{% block title %}视频监控 - Camera Pi{% endblock %}

{% block sidebar %}
<div class="list-group list-group-flush">
    <a href="/video/monitor" class="list-group-item list-group-item-action active">
        <i class="bi bi-camera-video"></i> 视频监控
    </a>
    <a href="/video/capture" class="list-group-item list-group-item-action">
        <i class="bi bi-camera"></i> 视频拍照
    </a>
    <a href="/video/face" class="list-group-item list-group-item-action">
        <i class="bi bi-person-badge"></i> 人脸识别
    </a>
</div>
{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12 mb-4">
            <h2><i class="bi bi-camera-video"></i> 视频监控</h2>
            <p class="lead">实时查看监控画面</p>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-9">
            <div class="card">
                <div class="card-body">
                    <div class="video-container">
                        <img src="{{ url_for('video_feed') }}" class="img-fluid" alt="视频流">
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col-md-3">
            <div class="card mb-3">
                <div class="card-body">
                    <h5 class="card-title"><i class="bi bi-sliders"></i> 控制面板</h5>
                    <div class="d-grid gap-2">
                        <button class="btn btn-primary" onclick="capture()">
                            <i class="bi bi-camera"></i> 拍照
                        </button>
                        <button class="btn btn-success" onclick="toggleFaceDetection()">
                            <i class="bi bi-person-badge"></i> 开启人脸识别
                        </button>
                        <button class="btn btn-info" onclick="toggleRecording()">
                            <i class="bi bi-record-circle"></i> 开始录制
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title"><i class="bi bi-clock-history"></i> 最近照片</h5>
                    <div class="recent-photos">
                        <!-- 这里将通过JavaScript动态加载最近的照片 -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
function capture() {
    fetch('/video/capture')
        .then(response => response.text())
        .then(message => {
            alert(message);
            loadRecentPhotos();
        })
        .catch(error => {
            console.error('Error:', error);
            alert('拍照失败，请重试');
        });
}

function toggleFaceDetection() {
    // 实现人脸识别开关功能
}

function toggleRecording() {
    // 实现视频录制功能
}

function loadRecentPhotos() {
    // 加载最近拍摄的照片
}
</script>
{% endblock %} 